package designs.moshi.ehan;
/*
* 饿汉模式单例
* */
public class Singleton {
    //静态变量存储唯一实例
    private   static  final Singleton instance=new Singleton();
    //私有化构造器
    private Singleton(){};

    //提供公开的获取实例的接口
    public static Singleton getInstance(){
        return instance;
    }

    public void show(){
        System.out.println("饿汉你干嘛");
        System.out.println(123);
        System.out.println(43);
        System.out.println(789);
        System.out.println(456);
    }


}

/*
public  class Singleton{
    //定义变量实例
    private static final Singleton instance=new Singleton();

    //私有化构造方法
    private Singleton(){};
    //提供静态公共接口
    public static Singleton getInstance(){
        return instance;
    }
}*/
